<?php
require "../util/DBUtil.php";
$categoryNo = $_GET['categoryNo'];  //获取书籍类型
//$categoryNo = 1;

$sql = "select book.* from book,type where book.typeNo = type.typeNo and type.categoryNo = ".$categoryNo;

$key = $_GET['key'];
//$key = "数学";
if ($key!=""){
    $sql = "select book.* from book,type where book.typeNo = type.typeNo and book.bookName like '%".$key."%' ";
}

$db = new DBUtil();
$resultSet = $db->query($sql);
if ($resultSet==""){
    echo "<script>alert('没有找到，请您重新搜索！');window.close()</script>";
    return;
}
?>
<link rel="stylesheet" href="../css/bootstrap.min.css">
<div class="container">
    <div class="row">
    <?php
    foreach ($resultSet as $result){
        ?>
        <a href="details.php?bookNo=<?php echo $result[bookNo] ?>"  target="_blank">
            <div class="col-md-2">
                <div class="thumbnail" style="height: 280px">
                    <img src=<?php echo '../img/' . $result[picture] ?> alt=<?php echo $result[bookName] ?>
                         class="img-responsive center-block"
                         width="360" title=<?php echo $result[bookName] ?> >
                    <div class="caption">
                        <p style="height:35px;overflow: hidden"><?php echo $result[bookName] ?></p>
                        <h3 style="color: #f42424">&yen;<?php echo $result[price] ?></h3>
                    </div>
                </div>
            </div>
        </a>

        <?php
    }
    $db->close();
    ?>
    </div>
</div>
